import request from '@/utils/request';

export function getAllGroups(): Promise<any> {
  return request('/api/auth/group/list', {
    method: 'GET',
    data: { page: 0 }, // page 传入0时取所有
  });
}

// 新增用户组
export function addGroup(data: object): Promise<any> {
  return request('/api/auth/group', {
    method: 'POST',
    data,
  });
}

// 修改用户组
export function updateGroup(id: string, data: object): Promise<any> {
  return request(`/api/auth/group/${id}`, {
    method: 'PUT',
    data,
  });
}

// 删除用户组
export function deleteGroup(id: string): Promise<any> {
  return request(`/api/auth/group/${id}`, {
    method: 'DELETE',
  });
}

// 获取用户组中的用户
export function getGroupUsers(id: string): Promise<any> {
  return request(`/api/auth/group/${id}/users`, { method: 'GET' });
}

// 修改用户组中的用户
export function updateGroupUsers(groupId: string, data: object): Promise<any> {
  return request(`/api/auth/group/${groupId}/users`, {
    method: 'PUT',
    data,
  });
}
